"""
Its easy to draw maps wih Tk!
"""
import sys

from Tkinter import Tk, Canvas

from gshhs import Parser

N=2

class Application(Tk, Parser):
    def __init__(self):
        Tk.__init__(self)
        w=self.canvas=Canvas(self, width=190*2*N, height=90*2*N)
        w.pack()
        self._points = []
        Parser.__init__(self, sys.argv[1])
        self.mainloop()
    def header(self, h=None):
        if h:
            self._header = h
        if not self._points:
            return
        if self._header.c == 'L':
            self.canvas.create_line(*self._points)
        else:
            self.canvas.create_polygon(*self._points, fill='', outline='black')
        self._points = []
    def point(self, p):
        self._points.append((p.lon+180)*N)
        self._points.append((90-p.lat)*N)
    def done(self):
        self.header()

Application()
